<?php

namespace Admin\Controller;

class ReplyController extends CommonController
{
    // 列表
    public function lists()
    {
        $sort = 'id desc';

        $map = array();

        $lists = D('BbsReply')->get_list($map, true, $sort, 10);

        $list = $lists['list'];
        $list = array_map(function($item){
            $item['adduser'] = D('User')->get_user_one($item['uid'], true);
            $item['bbs'] = D('Bbs')->get_bbs_one($item['bid']);
            return $item;
        }, $list);
        $lists['list'] = $list;

        $this->assign(compact('lists'));

        $this->display();
    }

    // 删除
    public function delete()
    {
        $ids = I('param.id');

        $ids = is_array($ids) ? implode(",", $ids) : $ids;
        if ($ids && is_match_ids($ids)) {
            D('BbsReply')->del_reply($ids);
            $this->success("成功删除");
        } else {
            $this->error('请选择要删除的信息！');
        }
    }
}